package com.hongxun.design.utils.projectdatautil;

import com.baidu.mapapi.model.LatLng;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zerdoor_pc .
 * author:dc
 * 2016/10/19.
 */
public class PointPaizi {

    public static Map<String, Object> exp_obj(LatLng curr, LatLng currbefore, LatLng currbeforebefore) {
        Double lng=curr.longitude;
        Double lat=curr.latitude;
        //选择的上联

        Double lng_b =currbefore.longitude;// Double.valueOf(before_obj.get("lng").toString());
        Double lat_b =currbefore.latitude;// Double.valueOf(before_obj.get("lat").toString());

        //选择的上联的上联
       // Map<String, Object> before_before_obj = this.findOneObject(sql_obj, new Object[]{before_before_id});
        Double lng_a = currbeforebefore.longitude;//Double.valueOf(before_before_obj.get("lng").toString());
        Double lat_a = currbeforebefore.latitude;//Double.valueOf(before_before_obj.get("lat").toString());

        //设上联的上联为点a，上联为点b，当前新踏勘点为c
        double distance_point_up = PointUtil.GetLongDistance(lng_a, lat_a, lng_b, lat_b);//a——b距离
        double distance_point_down = PointUtil.GetLongDistance(lng_b, lat_b, lng, lat);//b——c距离

        Double all_distance = distance_point_up + distance_point_down;

        //坐标更新计算
        double bz_distance = all_distance / distance_point_up;
        double cz_x = lng_b - lng_a;
        double cz_y = lat_b - lat_a;
        Double lng_up = bz_distance * cz_x + lng_a;
        Double lat_up = bz_distance * cz_y + lat_a;

        Map exp_obj = new HashMap();
        exp_obj.put("lng", lng_up);
        exp_obj.put("lat", lat_up);

        return exp_obj;
    }
}
